\documentclass[letterpaper]{article}
\usepackage{common/ohpc-doc}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

% Include git variables
\input{vc.tex}

% Define Base OS and other local macros
\newcommand{\baseOS}{SLES12SP4}
\newcommand{\OSRepo}{SLE\_12\_SP4}
\newcommand{\OSTree}{SLE\_12}
\newcommand{\OSTag}{sle12}
\newcommand{\baseos}{sles12sp4}
\newcommand{\baseosshort}{sles12}
\newcommand{\provisioner}{Warewulf}
\newcommand{\provheader}{\provisioner{}}
\newcommand{\rms}{SLURM}
\newcommand{\rmsshort}{slurm}
\newcommand{\arch}{aarch64}

% Define package manager commands
\newcommand{\pkgmgr}{zypper}
\newcommand{\addrepo}{zypper ar}
\newcommand{\chrootaddrepo}{wget -P \$CHROOT/etc/zypp/repos.d}
\newcommand{\clean}{zypper clean -a}
\newcommand{\chrootclean}{zypper --root \$CHROOT clean}
\newcommand{\install}{zypper -n install}
\newcommand{\chrootinstall}{zypper -n --root \$CHROOT install}
\newcommand{\groupinstall}{zypper -n install -t pattern}
\newcommand{\groupchrootinstall}{zypper -n --root \$CHROOT install -t pattern}
\newcommand{\remove}{zypper -n remove}
\newcommand{\upgrade}{zypper -n up}
\newcommand{\chrootupgrade}{zypper -n --root \$CHROOT up}
\newcommand{\tftppkg}{syslinux}

% boolean for os-specific formatting
\togglefalse{isCentOS}
\toggletrue{isaarch}
\toggletrue{isSLES_ww_slurm_aarch}
\toggletrue{isSLURM}
\toggletrue{isWarewulf}

\begin{document}
\graphicspath{{common/figures/}}
\thispagestyle{empty}

% Title Page --------------------------------------------------------
\input{common/title}
% Disclaimer
\input{common/legal} 

\newpage
\tableofcontents
\newpage

% Introduction  ----------------------------------------------------

\section{Introduction} \label{sec:introduction}
\input{common/install_header}
\input{common/intro} \\

\input{common/base_edition/edition}
\input{common/audience}
\input{common/requirements}
\input{common/inputs}

% Base Operating System --------------------------------------------

\section{Install Base Operating System (BOS)}
\input{common/bos}

% begin_ohpc_run
% ohpc_validation_newline
% ohpc_validation_comment Disable firewall 
\begin{lstlisting}[language=bash,keywords={}]
[sms](*\#*) systemctl disable SuSEfirewall2
[sms](*\#*) systemctl stop SuSEfirewall2
\end{lstlisting}
% end_ohpc_run

% ------------------------------------------------------------------

\section{Install \OHPC{} Components} \label{sec:basic_install}
\input{common/install_ohpc_components_intro.tex}

\subsection{Enable \OHPC{} repository for local use} \label{sec:enable_repo}
\input{common/enable_ohpc_repo}
\input{common/sles_os_repos}
\input{common/automation}

\subsection{Add provisioning services on {\em master} node} \label{sec:add_provisioning}
\input{common/install_provisioning_intro}

\input{common/enable_pxe}

\input{common/time}

\subsection{Add resource management services on {\em master} node} \label{sec:add_rm}
\input{common/install_slurm}

%% Add if/when IB is available for testing
%% \subsection{Optionally add \InfiniBand{} support services on {\em master} node} \label{sec:add_ofed}
%% \input{common/ibsupport_sms_sles}

\vspace*{-0.25cm}
\subsection{Complete basic Warewulf setup for {\em master} node} \label{sec:setup_ww}
\input{common/warewulf_setup}
\input{common/warewulf_setup_sles}
\input{common/warewulf_setup_aarch_db}

\vspace*{-0.25cm}
\subsection{Define {\em compute} image for provisioning}
\input{common/warewulf_mkchroot_sles}

\subsubsection{Add \OHPC{} components} \label{sec:add_components}
\input{common/add_to_compute_chroot_intro}

%\clearpage
% begin_ohpc_run
\begin{lstlisting}[language=bash,literate={-}{-}1,keywords={},upquote=true]
# Import GPG keys for chroot repository usage
[sms](*\#*) zypper -n --root $CHROOT --no-gpg-checks --gpg-auto-import-keys refresh

# Add SLURM client support meta-package
[sms](*\#*) (*\chrootinstall*) ohpc-slurm-client

# Provide udev rules to enable /dev/ipath access for InfiniPath devices
[sms](*\#*) cp /opt/ohpc/pub/examples/udev/60-ipath.rules $CHROOT/etc/udev/rules.d/

# Add Network Time Protocol (NTP) support
[sms](*\#*) (*\chrootinstall*) ntp

# Add kernel drivers
[sms](*\#*) (*\chrootinstall*) kernel-default

# Include modules user environment
[sms](*\#*) (*\chrootinstall*) lmod-ohpc

# Enable ssh access 
[sms](*\#*) chroot $CHROOT systemctl enable sshd.service

# Remove default hostname to allow WW to provision network names
[sms](*\#*) mv $CHROOT/etc/hostname $CHROOT/etc/hostname.orig
\end{lstlisting}
% end_ohpc_run

%\clearpage
\subsubsection{Customize system configuration} \label{sec:master_customization}
\input{common/warewulf_chroot_customize_sles}

% Additional commands when additional computes are requested

% begin_ohpc_run
% ohpc_validation_newline
% ohpc_validation_comment Update basic slurm configuration if additional computes defined
% ohpc_command if [ ${num_computes} -gt 4 ];then
% ohpc_command    perl -pi -e "s/^NodeName=(\S+)/NodeName=${compute_prefix}[1-${num_computes}]/" /etc/slurm/slurm.conf
% ohpc_command    perl -pi -e "s/^PartitionName=normal Nodes=(\S+)/PartitionName=normal Nodes=${compute_prefix}[1-${num_computes}]/" /etc/slurm/slurm.conf

% ohpc_command    perl -pi -e "s/^NodeName=(\S+)/NodeName=${compute_prefix}[1-${num_computes}]/" $CHROOT/etc/slurm/slurm.conf
% ohpc_command    perl -pi -e "s/^PartitionName=normal Nodes=(\S+)/PartitionName=normal Nodes=${compute_prefix}[1-${num_computes}]/" $CHROOT/etc/slurm/slurm.conf
% ohpc_command fi
% end_ohpc_run

%\clearpage
\subsubsection{Additional Customization ({\em optional})} \label{sec:addl_customizations}
\input{common/compute_customizations_intro}

%% Add if/when IB is available for testing
%% \paragraph{Increase locked memory limits}
%% \input{common/memlimits} 

\paragraph{Enable ssh control via resource manager} 
\input{common/slurm_pam}

%% \paragraph{Add \Lustre{} client} \label{sec:lustre_client}
%% \input{common/lustre-client}
%% \input{common/lustre-client}
%% \input{common/lustre-client-sles}
%% \input{common/lustre-client-post}

%\clearpage
\paragraph{Enable forwarding of system logs} \label{sec:add_syslog}
\input{common/syslog}


\paragraph{Add \Nagios{} monitoring}
\input{common/nagios}

\vspace*{0.35cm}
\paragraph{Add \Ganglia{} monitoring}
\input{common/ganglia}

%\clearpage
\paragraph{Add \clustershell{}}
\input{common/clustershell}

\paragraph{Add \mrsh{}}
\input{common/mrsh}

\paragraph{Add \genders{}}
\input{common/genders}

%\clearpage
\paragraph{Add \conman{}} \label{sec:add_conman}
\input{common/conman}

\paragraph{Add \nhc{}} \label{sec:add_nhc}
\input{common/nhc}
\clearpage
\input{common/nhc_slurm}

\subsubsection{Import files} \label{sec:file_import}
\input{common/import_ww_files}
\input{common/import_ww_files_slurm}
%% \input{common/import_ww_files_ib_sles}
\input{common/finalize_provisioning}
\input{common/add_ww_hosts_intro}
\input{common/add_ww_hosts_slurm}
\input{common/add_ww_hosts_finalize}

\vspace*{-0.2cm}
\subsubsection{Optional kernel arguments} \label{sec:optional_kargs}
\input{common/conman_post}
\input{common/kargs_post}

\subsubsection{Optionally configure stateful provisioning}
\input{common/stateful}

%\clearpage
\vspace*{0.4cm}
\subsection{Boot compute nodes} \label{sec:boot_computes}
\input{common/reset_computes}

\section{Install \OHPC{} Development Components} \label{sec:install_dev}
\input{common/dev_intro.tex}

\subsection{Development Tools} \label{sec:install_dev_tools}
\input{common/dev_tools}

\subsection{Compilers} \label{sec:install_compilers}
\input{common/compilers}

\subsection{MPI Stacks} \label{sec:mpi}
\input{common/mpi_aarch}

\subsection{Performance Tools} \label{sec:install_perf_tools}
\input{common/perf_tools}

\subsection{Setup default development environment}
\input{common/default_dev}

\subsection{3rd Party Libraries and Tools} \label{sec:3rdparty}
\input{common/third_party_libs_intro}
\input{common/third_party_libs_petsc_sles}
\input{common/third_party_libs}
\input{common/third_party_mpi_libs_aarch}

\clearpage
\section{Resource Manager Startup} \label{sec:rms_startup}
\input{common/slurm_startup}

%\clearpage
%\vspace*{-1cm}
\section{Run a Test Job} \label{sec:test_job}
\input{common/slurm_test_job}

\clearpage
\appendix
{\bf \LARGE \centerline{Appendices}} \vspace*{0.2cm}

\addcontentsline{toc}{section}{Appendices}
\renewcommand{\thesubsection}{\Alph{subsection}}

\input{common/automation_appendix}
\input{common/upgrade}
\input{common/test_suite}
\input{common/customization_appendix_sles}
\input{manifest}
\input{common/signature}


\end{document}

